/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.view.purchaseView;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableCellEditor;

import com.ruipengkj.ApplicationContext;
import com.ruipengkj.bean.TBillDetail;
import com.ruipengkj.bean.TEmployee;
import com.ruipengkj.bean.TPurchaseReturn;
import com.ruipengkj.bean.TStockInOut;
import com.ruipengkj.bean.TStore;
import com.ruipengkj.bean.TSupplier;
import com.ruipengkj.commons.BuildSpringApplication;
import com.ruipengkj.commons.util.IDNameBean;
import com.ruipengkj.commons.util.TabelUtil;
import com.ruipengkj.commons.util.UUID;
import com.ruipengkj.commons.util.Util;
import com.ruipengkj.component.JComboBoxPOJO;
import com.ruipengkj.component.JLabelJComboBoxComponent;
import com.ruipengkj.component.JLabelJTextFieldComponent;
import com.ruipengkj.component.JPanelFlowLayoutComponent;
import com.ruipengkj.component.RPJButtonRoundBlue;
import com.ruipengkj.component.RPJButtonRoundOrager;
import com.ruipengkj.component.RPJButtonWhite;
import com.ruipengkj.component.comboBox.CommodityJComboBoxTableReturn;
import com.ruipengkj.component.jdialog.BorderJPanel;
import com.ruipengkj.component.jdialog.IDialog;
import com.ruipengkj.component.jpanel.RepeatImagePanel;
import com.ruipengkj.factory.ImageFactory;
import com.ruipengkj.model.PuchaseRetreatAddModel;
import com.ruipengkj.service.TBillDetailService;
import com.ruipengkj.service.TCommodityService;
import com.ruipengkj.service.TEmployeeService;
import com.ruipengkj.service.TPurchaseReturnService;
import com.ruipengkj.service.TStockInOutService;
import com.ruipengkj.service.TStoreService;
import com.ruipengkj.service.TSupplierService;
/**
 * 说明：
 * 退货添加窗口
 * @Author：黄盛强
 * @Date：2012-03-26
 */
public class PurchaseRetreatAddPanel extends IDialog {

private static final long serialVersionUID = 1L;
	
	private JLabelJTextFieldComponent returnedID; //退货单
	
	private JLabelJComboBoxComponent vendor = null;//供应商
	private JLabelJComboBoxComponent store;//仓库
	
	private JLabelJComboBoxComponent employee = null; //退货人
	private JLabelJTextFieldComponent numTF;//数量
	private JLabelJTextFieldComponent moneyTF;//金额
	private JLabelJTextFieldComponent storageQuantityTF;//存库量
	
	
	private JLabelJTextFieldComponent reason;//原因
	
	private JButton addButton; //添加行
	private JButton delButton; //删除行
	//private JButton delAllButton;//删除此表
	private JButton saveExitButton; //保存退出
	private JButton saveButton; //保存新增
	private JButton exitButton; //直接退出
	
	private JTable table;
	private JScrollPane tableJsp;
	private PuchaseRetreatAddModel puchaseRetreatAddModel;
	
	private TCommodityService tCommodityService;//商品
	private TStoreService tStoreService;//仓库
	private TSupplierService tSupplierService;//供货商单
	private TStockInOutService tStockInOutService;//入/出库单
	private TBillDetailService tBillDetailService;//单据商品明细
	private TPurchaseReturnService tPurchaseReturnService;//退货
	private TEmployeeService tEmployeeService;//员工
	private TPurchaseReturn tPurchaseReturn;//退货
	public boolean isSuccess = true; 
	private CommodityJComboBoxTableReturn cbox;
	private int select = 0;
	public PurchaseRetreatAddPanel(JDialog jd, String title, boolean b) {
		super(jd, title, b);
		tStoreService = BuildSpringApplication.getInstance().getTStoreServiceImpl();
		tSupplierService = BuildSpringApplication.getInstance().getTSupplierServiceImpl();
		tStockInOutService = BuildSpringApplication.getInstance().getTStockInOutServiceImpl();
		tPurchaseReturnService = BuildSpringApplication.getInstance().getTPurchaseReturnServiceImpl();
		tCommodityService = BuildSpringApplication.getInstance().getTCommodityServiceImpl();
		tBillDetailService = BuildSpringApplication.getInstance().getTBillDetailServiceImpl();
		tEmployeeService= BuildSpringApplication.getInstance().getTEmployeeServiceImpl();
		this.init();
		this.initListener();
		this.setSize(900, 600);
		this.setResizable(false);
		this.setLocationRelativeTo(null);
	}
	private void init() {
		puchaseRetreatAddModel = new PuchaseRetreatAddModel();
		puchaseRetreatAddModel.setEditable(true);
		table=uiFactory.createRPJTable(puchaseRetreatAddModel, this, this, 30, JLabel.CENTER);
		cbox = new CommodityJComboBoxTableReturn();
		cbox.setBorder(null);
		TableCellEditor edt = new DefaultCellEditor(cbox);
		table.getColumnModel().getColumn(2).setCellEditor(edt);
		table.getColumnModel().getColumn(3).setCellEditor(edt);
		tableJsp=uiFactory.createJScrollPane(table);
		JPanel main_jp=new BorderJPanel(new BorderLayout());
		main_jp.setBackground(Util.PANEL_COLOR);
		main_jp.add(this.initTop(), BorderLayout.NORTH);
		main_jp.add(tableJsp, BorderLayout.CENTER);
		main_jp.add(this.initTail(), BorderLayout.SOUTH);
		this.add(main_jp);
		main_jp.setCursor(Util.CURSOR_DEFAULT);
		
		TabelUtil.hideTableColumn(0, table);
	}
	private JPanel initTop() {
		returnedID = new JLabelJTextFieldComponent("    退货单：", 30);
		returnedID.getText().setEditable(false);
		returnedID.getText().setText(UUID.GenUUID15());
		store = new JLabelJComboBoxComponent("  退货仓库：", new String[]{}, 188);
		store.addElement(new JComboBoxPOJO("请选择……"));
		JLabelJTextFieldComponent operator = new JLabelJTextFieldComponent("    操作员：", 30);
		operator.getText().setText(ApplicationContext.OPERATOR_NAME);
		operator.getText().setEditable(false);
		JPanel jp1 = new JPanelFlowLayoutComponent(new Component[]{returnedID, store,operator}, FlowLayout.LEFT);
		employee = new JLabelJComboBoxComponent("    退货人：", new String[]{},180);
		employee.addElement(new IDNameBean("0", "请选择"));
		vendor = new JLabelJComboBoxComponent("退货供应商：", new String[]{},188);
		vendor.addElement(new JComboBoxPOJO("请选择……"));
		reason = new JLabelJTextFieldComponent("退货原因：", 30);//原因
		JPanel jp2 = new JPanelFlowLayoutComponent(new Component[]{vendor, employee,reason}, FlowLayout.LEFT);

		JPanel top_panel = new RepeatImagePanel(ImageFactory.loadImage(ImageFactory.DIALOG_TOP_BG_2).getImage());
		top_panel.setLayout(new GridLayout(2, 1));
		top_panel.add(jp1);
		top_panel.add(jp2);
		return top_panel;
	}
	
	private JPanel initTail() {
		JPanel tail_panel = new RepeatImagePanel(ImageFactory.loadImage(ImageFactory.DIALOG_TOP_BG_2).getImage());
		tail_panel.setLayout(new GridLayout(2, 1));
		
		JPanel jp8 = uiFactory.createFlowJPanel(FlowLayout.LEFT);
		addButton = new RPJButtonRoundBlue("添加行");
		delButton = new RPJButtonRoundOrager("删除行");
		jp8.add(addButton);
		jp8.add(delButton);
		
		JPanel jp1 = uiFactory.createFlowJPanel(FlowLayout.LEFT);
		numTF = new JLabelJTextFieldComponent("合计：数量", 10);
		numTF.getText().setText("0");
		numTF.getText().setEditable(false);
		moneyTF = new JLabelJTextFieldComponent("金额：", 10);
		moneyTF.getText().setText("0.0");
		moneyTF.getText().setEditable(false);
		storageQuantityTF = new JLabelJTextFieldComponent("当前库存量：", 10);
		storageQuantityTF.getText().setText("0");
		storageQuantityTF.getText().setEditable(false);
		jp1.add(numTF);
		jp1.add(moneyTF);
		jp1.add(storageQuantityTF);
		
		saveExitButton = new RPJButtonWhite("保存退出(Ctrl+S)");
		saveButton = new RPJButtonWhite("保存新增(Ctrl+I)");
		exitButton = new RPJButtonWhite("直接退出(Ctrl+Q)");
		jp1.add(saveExitButton);
		jp1.add(saveButton);
		jp1.add(exitButton);
		
		tail_panel.add(jp8);
		tail_panel.add(jp1);
		return tail_panel;
	}
	
	@Override
	protected java.awt.Dimension getTitleSize() {
		return new Dimension(126, 29);
	};
	
	private void initListener() {
		addButton.addActionListener(this);
		delButton.addActionListener(this);
		saveExitButton.addActionListener(this); //保存退出
		saveExitButton.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
		saveButton.addActionListener(this); //保存新增
		saveButton.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
		exitButton.addActionListener(this); //直接退出
		exitButton.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
		store.getBox().addActionListener(this);
		puchaseRetreatAddModel.addTableModelListener(new TableModelListener() {
			@Override
			public void tableChanged(TableModelEvent e) {
				int row=table.getSelectedRow();
				if(row!=-1 && row < puchaseRetreatAddModel.getRowCount()){
					Object obj=table.getValueAt(row, 2);
					if(obj!=null){
						JComboBoxPOJO storePO=(JComboBoxPOJO)store.getBox().getSelectedItem();
						ApplicationContext.countStoreNumber(puchaseRetreatAddModel.findAllBillDetailList(), (TStore)storePO.getObject(), obj.toString(), numTF.getText(), moneyTF.getText(), storageQuantityTF.getText());
					}
				}
			}
		});
	}
	
	//数据库中的数据放入list（读取数据）
	private Runnable queryBillDetail=new Runnable() {
		@Override
		public void run() {
			List<TBillDetail> list = null;
			try {
				addButton.setEnabled(false);
				delButton.setEnabled(false);
				saveExitButton.setEnabled(false);
				saveButton.setEnabled(false);
				TBillDetail tBillDetail = new TBillDetail();
				tBillDetail.setBillID(tPurchaseReturn.getReturnID());
				tBillDetail.setBillType(ApplicationContext.BILL_BILLTYPE2);
				list = tBillDetailService.findService(tBillDetail);
				if (list != null &&  list.size()!= 0) {
					int length = list.size();
					for (int i = 0; i < length; ++i) {
						//获取商品 以便查看
						list.get(i).setCommodity(tCommodityService.findByIdService(list.get(i).getCommodityID()));
						//添加进列表
						puchaseRetreatAddModel.addBillDetail(list.get(i));
					}
				}
				ApplicationContext.countStoreNumber(puchaseRetreatAddModel.findAllBillDetailList(), null, null, numTF.getText(), moneyTF.getText(), storageQuantityTF.getText());
				
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	};
	
	public void showDialog(String purchaseID) {
		try {
			TPurchaseReturn tPurchaseReturn = null;
			if (purchaseID != null && !purchaseID.equals(""))
				tPurchaseReturn = tPurchaseReturnService.getByIdService(purchaseID);
			showDialog(tPurchaseReturn);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void showDialog(TPurchaseReturn tPurchaseReturn){
		this.tPurchaseReturn = tPurchaseReturn;
		if (tPurchaseReturn != null) {
			puchaseRetreatAddModel.setEditable(false);
			reason.getText().setText(tPurchaseReturn.getReason());
			returnedID.getText().setText(tPurchaseReturn.getReturnID());
			
			//供货商
			if (tPurchaseReturn.getSupplierID() != null && tPurchaseReturn.getSupplierID() != null){
				String id=tPurchaseReturn.getSupplierID();
				TSupplier tSupplier= null;
				try {
					tSupplier = tSupplierService.getByIdService(id);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				vendor.addElement(new JComboBoxPOJO(tPurchaseReturn.getSupplierID(),tSupplier.getName(),tPurchaseReturn.getSupplierID()));
				vendor.getBox().setSelectedIndex(1);
			}
			
			TStockInOut tStockInOut = new TStockInOut();//取出   出入库存单
			tStockInOut.setSourceType((byte)2);
			tStockInOut.setSource(tPurchaseReturn.getReturnID());
			try {//取出出入库存单中的仓库
				List<TStockInOut> tStockInOutlist = tStockInOutService.findService(tStockInOut);
				if(tStockInOutlist!=null&&tStockInOutlist.size()!=0){
					TStore tStore = tStockInOutlist.get(0).getTStore();
					store.addElement(new JComboBoxPOJO(tStore.getStoreID(), tStore.getName(), tStore));
					store.getBox().setSelectedIndex(1);
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
			SwingUtilities.invokeLater(queryBillDetail);
		} else {
			SwingUtilities.invokeLater(querySupplier);
			SwingUtilities.invokeLater(queryStore);
		}
		SwingUtilities.invokeLater(queryEmp);
		this.setVisible(true);
	}
	public boolean addOrderReturn(){
		List<TBillDetail> modelList=puchaseRetreatAddModel.findAllBillDetailList();
		if (modelList.size() <= 0) {
			JOptionPane.showMessageDialog(null, "请添加商品，在进行新增操作！");
			return false;
		}
		if(store.getBox().getSelectedIndex()==0){
			JOptionPane.showMessageDialog(null, "请选择仓库，在进行新增操作！");
			return false;
		}
		if (employee.getBox().getSelectedIndex()==0) {
			JOptionPane.showMessageDialog(null, "请选择退货人！");
			return false;
		}
		if (vendor.getBox().getSelectedIndex()==0) {
			JOptionPane.showMessageDialog(null, "请选择退货商！");
			return false;
		}
		
		JComboBoxPOJO storePo=(JComboBoxPOJO)store.getBox().getSelectedItem();//仓库
		
		TStore tStore = (TStore)storePo.getObject();
		
		boolean okNull = false;//记录是否允许价格为空，放置消息框无限弹出
		for (int i = 0; i < modelList.size(); ++i) {
			TBillDetail tBillDetail = modelList.get(i);
			if (tBillDetail.getCommodityID() == null || tBillDetail.getCommodityID().length() == 0) {
				JOptionPane.showMessageDialog(null, "存在商品编号为空的商品！");
				return false;
			}
			if (tBillDetail.getNum() == 0) {
				JOptionPane.showMessageDialog(null, "存在商品数量为0的商品！");
				return false;
			} 
			if (tBillDetail.getPrice() <= 0 && !okNull) {
				if(Util.showConfirmDialog("允许商品的价格不大于零？")!=0) {
					return false;
				} else {
					okNull = true;
				}
			} 
			int num = ApplicationContext.stockTotalNum(tBillDetail.getCommodityID(), tStore.getStoreID());//selectStorageQuantity(tBillDetail);
			if (num - tBillDetail.getNum() < 0) {
				JOptionPane.showMessageDialog(null, "第" + (i+1) + "件商品，在当前仓库库存量不足，请正确填写退货数量！");
				return false;
			}
			if (num - tBillDetail.getNum() <= 10) {
				if(Util.showConfirmDialog("第" + (i+1) + "件商品，在当前仓库库存量只剩 " + num + " 件，确定退货 " + tBillDetail.getNum() + " 件吗？")!=0) {
					return false;
				}
			}
		}
		
		JComboBoxPOJO po = (JComboBoxPOJO)vendor.getBox().getSelectedItem();
		
		IDNameBean bean=(IDNameBean)employee.getBox().getSelectedItem();//退货人
		//添加采购退货单
		if(tPurchaseReturn == null) {
			tPurchaseReturn = new TPurchaseReturn();
		}
		tPurchaseReturn.setReturnID(returnedID.getText().getText().trim());
		tPurchaseReturn.setEmployee(bean.getStrId());
		tPurchaseReturn.setOperator(ApplicationContext.OPERATOR_ID);
		tPurchaseReturn.setReason(reason.getText().getText().trim());
		tPurchaseReturn.setHappenTime(new Date());
		tPurchaseReturn.setAuditTime(new Date());
		tPurchaseReturn.setSupplierID(po.getIdStr());
		
		try {
			tPurchaseReturnService.saveService(tPurchaseReturn);
			ApplicationContext.addInOutBillDetailMoney(modelList, tStore,ApplicationContext.STOCK_IN_OUT_SOURCE_TYPE2,ApplicationContext.STOCK_TYPE_OUT,returnedID.getText().getText().trim(),ApplicationContext.MONEYINOUT_TYPE_IN,ApplicationContext.MONEYINOUT_SOURCE_TYPE2,bean.getStrId());
			BuildSpringApplication.getInstance().getTOpLogServiceImpl().addOpLogService("添加退货单信息");
		} catch (Exception e) {
			e.printStackTrace();
		}
		isSuccess=true;
		return true;
	}
	
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == addButton) {
			//添加
			if (store.getBox().getSelectedIndex() == 0) {
				JOptionPane.showMessageDialog(null, "请先选择退货仓库！");
				return;
			}
			if (vendor.getBox().getSelectedIndex() == 0) {
				JOptionPane.showMessageDialog(null, "请先选择退货供应商！");
				return;
			}
			TBillDetail tBillDetail=new TBillDetail();
			tBillDetail.setDetailID(UUID.GenUUID15());
			tBillDetail.setNum(1);
			tBillDetail.setBillID(returnedID.getText().getText());
			tBillDetail.setBillType(ApplicationContext.BILL_BILLTYPE2);
			puchaseRetreatAddModel.addBillDetail(tBillDetail);
			TableCellEditor edt = new DefaultCellEditor(cbox);
			table.getColumnModel().getColumn(2).setCellEditor(edt);
			table.getColumnModel().getColumn(3).setCellEditor(edt);
		} else if(e.getSource() == delButton) {
			//删除
			if(table.getRowCount()==0){
				JOptionPane.showMessageDialog(null, "当前数据为空");
				return;
			}else{
				List<Integer> ints=new ArrayList<Integer>();
				int select[] = table.getSelectedRows();
				if (select != null && select.length != 0) {
					for (int i = 0; i < select.length; ++i) {
						ints.add(select[i]);
					}
				}
//				for(int i=0;i<puchaseRetreatAddModel.findAllBillDetailList().size();i++){
//					TBillDetail billDetail=puchaseRetreatAddModel.findAllBillDetailList().get(i);
//					if(billDetail.isFlag()){
//						ints.add(i);
//					}
//				}
				if(ints.size()!=0){
					if(JOptionPane.showConfirmDialog(null, "是否要删除选中行？","提示",JOptionPane.OK_CANCEL_OPTION)==0){
						for(int i=ints.size()-1;i>=0;i--){
							puchaseRetreatAddModel.delBillDetail(ints.get(i));
						}
					}
				}else{
					JOptionPane.showMessageDialog(null, "请先选择你需要删除的行");
				}
				ints.clear();
			}
		} else if(e.getSource() == saveExitButton) {//保存退出
			if(this.addOrderReturn()){
				this.dispose();
			}
		} else if(e.getSource() == saveButton) {//保存
			if(this.addOrderReturn()){
				puchaseRetreatAddModel.clearAllBillDetail();
				this.employee.getBox().setSelectedIndex(0);
				this.reason.getText().setText("");
				this.returnedID.getText().setText(UUID.GenUUID15());
				table.updateUI();
			}
		} else if(e.getSource() == exitButton) {//退出
			if(Util.showConfirmDialog("是否要退出？")==0){
				this.dispose();
			}
		} else if (e.getSource() == store.getBox()) {
			if (select == 0 || select == store.getBox().getSelectedIndex()) {
				select = store.getBox().getSelectedIndex();
				setStore();
				return;
			}
			if (table.getRowCount() > 0) {
				if (Util.showConfirmDialog("切换仓库将清空当前列表数据，是否切换？")==0) {
					select = store.getBox().getSelectedIndex();
					puchaseRetreatAddModel.clearAllBillDetail();
					setStore();
					table.updateUI();
				} else {
					store.getBox().setSelectedIndex(select);
				}
			}
		} else {
			super.actionPerformed(e);
		}
	}
	@Override
	public void mouseClicked(MouseEvent e) {
		if (e.getSource() == table) {
			table.updateUI();
			Object obj=table.getValueAt(table.getSelectedRow(), 2);
			if(obj!=null){
				JComboBoxPOJO storePO=(JComboBoxPOJO)store.getBox().getSelectedItem();
				ApplicationContext.countStoreNumber(puchaseRetreatAddModel.findAllBillDetailList(), (TStore)storePO.getObject(), obj.toString(), numTF.getText(), moneyTF.getText(), storageQuantityTF.getText());
			}
		}
	}
	//读取供货商数据
	private Runnable querySupplier=new Runnable() {
		@Override
		public void run() {
			try {
				List<TSupplier> tSupplierList = tSupplierService.findService(null);
				if (tSupplierList != null && tSupplierList.size()!=0) {
					int length = tSupplierList.size();
					for(int i = 0; i < length; ++i) {
						TSupplier supplie=tSupplierList.get(i);
						vendor.addElement(new JComboBoxPOJO(supplie.getSupplierID(),supplie.getName(),supplie));
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	};
	
	//读取仓库数据
	private Runnable queryStore=new Runnable() {
		@Override
		public void run() {
			try {
				List<TStore> tStoreList = tStoreService.findService(null);
				if (tStoreList != null && tStoreList.size()!=0) {
					int length = tStoreList.size();
					for(int i = 0; i < length; ++i) {
						TStore tStore=tStoreList.get(i);
						store.addElement(new JComboBoxPOJO(tStore.getStoreID(),tStore.getName(),tStore));
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	};
	//设置条件仓库
	private void setStore(){
		if(store.getBox().getSelectedIndex() != 0) {
			JComboBoxPOJO storePo=(JComboBoxPOJO)store.getBox().getSelectedItem();//仓库
			cbox.settStore((TStore)storePo.getObject());
			table.updateUI();
		}
	}
	//读取采购员
	public Runnable queryEmp=new Runnable() {
		@Override
		public void run() {
			try {
				List<TEmployee> list=tEmployeeService.findService(null);
				if(list!=null&&list.size()!=0){
					for(int i=0;i<list.size();i++){
						TEmployee emp=list.get(i);
						employee.addElement(new IDNameBean(emp.getEmployeeID(), emp.getName()));
						if(tPurchaseReturn!=null){
							if(emp.getEmployeeID().equals(tPurchaseReturn.getEmployee())){
								employee.getBox().setSelectedIndex(i+1);//退货人
							}
						}
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	};
	
	public static void main(String[] args) {
		PurchaseRetreatAddPanel dialog = new PurchaseRetreatAddPanel(null, "添加部门", true);
		dialog.setVisible(true);
	}
}
